<?php
function theme_widget_site_member($setting,&$smarty){
	 $member =array();
	 $userObject = kernel::single('b2c_user_object');	
     $member = $userObject->get_current_member();	 
	 $member_id = $member['member_id'];
	 if ($member_id) {
		 $dbs=kernel::database();	 
		 //获取会员等级
		 $obj_mem_lv = app::get('b2c')->model('member_lv');	 
		 $levels = $obj_mem_lv->getList('name,disabled',array('member_lv_id'=>$member['member_lv']));
		 if($levels[0]['disabled']=='false'){
			$member['levelname'] = $levels[0]['name'];
		 }
		 
		 //获取会员等级logo
		 $sql0="SELECT lv_logo FROM `sdb_b2c_member_lv` WHERE member_lv_id=".$member['member_lv'];
		 $lv_logo = $dbs->selectrow("$sql0");
		 //print_r($lv_logo);exit;
		 $member['lv_logo'] = base_storager::image_path($lv_logo['lv_logo']);
		
		 //获取未读站内信数量 
		 $oMsg = kernel::single('b2c_message_msg');
		 ///////////////////////////////////////////////////edit by 黄智坤  //增加判断发送给当前会员的id筛选
		 $row = $oMsg->getList('*',array('mem_read_status' => 'false','to_id'=>$member_id));
//echo'<pre>';
//echo '<br>';
//var_dump($member_id);
//echo '<br>';
//var_dump($row);
//exit;		 
 ///////////////////////////////////////////////////end

$member['newmsg'] = count($row)?count($row):0;
		 
		 //获取咨询评论数
		 $mem_msg = app::get('b2c')->model('member_comments');
		 $object_type = array('discuss','ask');
		 $aData = $mem_msg->getList('*',array('to_id' => $member_id,'object_type'=> $object_type,'mem_read_status' => 'false','display' => 'true'));
		 $member['discuss']=count($aData)?count($aData):0;
		 
		 //到货通知
		 $member_goods = app::get('b2c')->model('member_goods');	 
		 $member['sto_goods_num'] = $member_goods->get_goods($member_id);
		 
		 //收藏商品数	
		 $sql1="SELECT COUNT(*) AS count FROM `sdb_b2c_member_goods` WHERE type='fav' AND member_id=".$member_id;
		 $favorite=mysql_fetch_array(mysql_query($sql1));
		 $member['favorite'] =  $favorite['count'];
		 
		 /*最新订单 剃除状态为已完成的订单*/
		 $sql2="SELECT COUNT(*) AS count FROM `sdb_b2c_orders` WHERE status!='finish' AND member_id=".$member_id;
		 $neworder=mysql_fetch_array(mysql_query($sql2));
		 $member['neworder'] =  $neworder['count'];
		 //取值【支付方式】是否启用预存款，判断前端是否显示 我的预存款 
		 //前端页面 default.html 进行判断
		 //createby:karson date:20170426
//获取支付页面信息

		 // $lmparam_obj = kernel::single('ectools_mdl_payment_cfgs');
   //$lmparam = $lmparam_obj->getList('*');
// $payment_cfgs_model=app::get('ectools')->model('payment_cfgs');
// $payment_cfgs_data=$payment_cfgs_model->getList('*',array('app_name'=>"预存款"));
//  $member['app_staus']=$payment_cfgs_data[0]['app_staus'];
// var_dump($lmparam );
//如下代码获取 支付方式 配置信息
         $pay_app_config = app::get('ectools')->getConf('ectools_payment_plugin_deposit');
         $pay_app_config = unserialize($pay_app_config);
         $member['app_staus'] = $pay_app_config['status'];

 
	 // print_r($pay_app_config['setting']);
	 // exit;

	 } 
	 //print_r($member);exit;
     return $member;
}
?>
